<?php
$setUpPersonInfoStr = Yii::t('BWeSport', 'set up  person info');
$setUpEmailStr = Yii::t('BWeSport', 'set up email');
$setUpLoginIdStr = Yii::t('BWeSport', 'set up login Id');
$setUpUserNameStr = Yii::t('BWeSport', 'set up user name');
$setUpMobileStr = Yii::t('BWeSport', 'set up mobile');
$loginIdStr = Yii::t('BWeSport', 'Login Id');
$userNameStr = Yii::t('BWeSport', 'User Name');
$emailStr = Yii::t('BWeSport', 'Email');
$mobileStr = Yii::t('BWeSport', 'mobile');
//$teacherNoStr = Yii::t('BWeSport', 'teacherNo');
$saveStr = Yii::t('BWeSport', 'Save');
$cancelModifyStr = Yii::t('BWeSport', 'cancel modify');
?>
<style>
    .form-signin {
        max-width: 330px;
        padding: 15px;
        margin: 0 auto;
    }
    .form-signin .form-signin-heading,
    .form-signin .checkbox {
        margin-bottom: 10px;
    }
    .form-signin .checkbox {
        font-weight: normal;
    }
    .form-signin .form-control {
        position: relative;
        height: auto;
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
        padding: 10px;
        font-size: 16px;
    }
    .form-signin .form-control:focus {
        z-index: 2;
    }
    .form-signin input[type="email"] {
        margin-bottom: -1px;
        border-bottom-right-radius: 0;
        border-bottom-left-radius: 0;
    }
    .form-signin input[type="password"] {
        margin-bottom: 10px;
        border-top-left-radius: 0;
        border-top-right-radius: 0;
    }
#ajax-loaderdiv {position: fixed;top: 0;left: 0;width: 100%;height: 100%;z-index: 35000;background-color: rgba(0, 0, 0, 0.3);display: none;}
.ajax-loader {position: absolute;left: 50%;top: 50%;margin-left: -16px;margin-top: -16px;display: block;}
</style>
<div id="ajax-loaderdiv" style="display: none;">
    <img src="/billyn-dev/images/ajax-loader.gif" class="ajax-loader">
</div>
<?php
$openid = '';
if (isset($_GET["openid"])) {
     $openid=$_GET["openid"];
}
?>
<?php
$user = Blyn::app()->getCurrentUser();
$attributes = $user->getAttributes();

$model = new BDynamicFormModel();
$emailField = 'media_email_userInfo';
$userNameField = 'media_userName_userInfo';
$userIdField = 'media_userId_userInfo';
$mobileField = 'media_mobile_userInfo';
$openidField = 'media_openid_userInfo';
//$teacherNoField = 'media_teacherNo_userInfo';

$model->addField($emailField);
$model->addField($userNameField);
$model->addField($userIdField);
$model->addField($mobileField);
$model->addField($openidField);
//$model->addField($teacherNoField);

$model->$emailField = $user->email;
$model->$userNameField = $user->userName;
$model->$userIdField = $user->userId;

$userInfo = $user->getAttribute('userInfo');
$attributes = array();
//$teacherNoAttr = ' ';
$mobileAttr = ' ';
$openidAttr = ' ';
if ($userInfo) {
    $attributes = $userInfo->getChildren();
    foreach ($attributes as $attr) {
        if($attr->getName() == 'mobile')
            $mobileAttr = $attr->getValue();
        if($mobileAttr != NULL)
            $model->$mobileField = $mobileAttr;
//        if($attr->getName() == 'teacherNo')
//            $teacherNoAttr = $attr->getValue();
//        if($teacherNoAttr != NULL)
//            $model->$teacherNoField = $teacherNoAttr;
        if($attr->getName() == 'openid')
            $openidAttr = $attr->getValue();
        if($openidAttr != NULL)
            $model->$openidField = $openidAttr;
    }
    
}
//$mobileAttr = $user->getAttribute('mobile');
//if ($mobileAttr != NULL) {
//    $model->$mobileField = $mobileAttr->getValue();
//}
?>

<div class="container">
    <?php
    $form = $this->beginWidget('CActiveForm', array(
        "id" => "manage-myInfo-form",
        'enableAjaxValidation' => FALSE,
        'htmlOptions' => array('class' => 'form-signin', 'role' => 'form'),
    ));
    ?>
    <h3 class="form-signin-heading text-muted"><?php echo '提供认证信息';?></h3>
    <?php
    echo '<br><p>';
//    echo CHtml::label('邮箱'.'：', 'email');
//    echo CHtml::activeTextField($model, $emailField, array(
//        'class' => 'form-control',
//        'placeholder' => $emailStr.'...', 'required' => 'true', 'autofocus' => 'true'));
//    echo '</p><p>';
//    echo CHtml::label('登录名'.'：', 'userId');
//    echo CHtml::activeTextField($model, $userIdField, array(
//        'class' => 'form-control',
//        'placeholder' => $loginIdStr.'...',
//        'required' => 'true'));
//    echo '</p><p>';
    echo CHtml::label('用户名'.'：', 'userName');
    echo CHtml::activeTextField($model, $userNameField, array(
        'class' => 'form-control',
        'placeholder' => $userNameStr.'...',
        'required' => 'true'));
    echo '</p><p>';
    echo CHtml::label('手机号码'.'：', 'mobile');
    echo CHtml::activeTextField($model, $mobileField, array(
        'class' => 'form-control',
        'placeholder' => $mobileStr.'...',
        'required' => 'true'));
        echo '</p><p>';
//    echo CHtml::label('教职工号'.'：', 'mobile');
//    echo CHtml::activeTextField($model, $teacherNoField, array(
//        'class' => 'form-control',
//        'placeholder' => $teacherNoStr.'...',
//        'required' => 'true'));
    echo CHtml::activeTextField($model, $openidField, array(
        'class' => 'form-control',
        'value'=>$openid,
        'style'=>'display:none',
        'required' => 'true'));
    echo '</p>';
    ?>
    <label></label>
    <?php
    echo $control->getAjaxLink(
            array('name' => '认证信息', 'id' => 'authenticateUserHamshun'), array(
        'htmlOptions' => array(
            'class' => 'btn btn-primary btn-lg btn-block')));
    ?>
    <?php
//    echo $control->getAjaxLink(
//            array('name' => '显示用户信息', 'id' => 'displayUserInfo'), array(
//        'htmlOptions' => array(
//            'class' => 'btn btn-info btn-lg btn-block')));
    ?>
    <?php $this->endWidget(); ?>
</div>